public class Test {
    public static void main(String[] args) {
        int a = 5;
        int b = 2;
        double c = a*1.0/b;
        System.out.println(c);

    }
    public static void main6(String[] args) {
        String str1 = "100";
        int num= Integer.parseInt(str1);//string转换int

        System.out.println(num+1);

    }
    public static void main5(String[] args) {
        int num = 10;
        String str1 = num+ "haha";//方法一：直接用”+“拼接，赋予字符串类型
        String str2 = String.valueOf(num); //整型转换为字符串类型
        String str3 = String.valueOf(12.3);//浮点型转换为字符串类型

    }
    public static void main4(String[] args) {
        String str1 ="hello";
        String str2 =" world";
        String str3 = str1 + str2;
        System.out.println(str3);
    }
    public static void main3(String[] args) {
        int a =10;
        long b =20L;
         //此时报错是因为，int + long会提升为long型，不能将值赋给int型变量
        long d = a+b;//编译正常

        byte e = 10;
        byte f = 20;
        int m = e+f;


    }

    public static void main2(String[] args) {
        int a = 100;
        long b = 1L;
        b = a;

        long c = 100L;
        int d = (int)c; //将long型强制转换为int型赋予d，赋值编译失败

        double  m = 10.0;
        float n =(float)m; //将double型强制转换为float型赋予n，赋值编译失败

        byte f = 100; //100默认为int型，自动类型转换为byte
        byte g = (byte)128; //128默认为int型，且超过byte范围，需要强制类型转换
    }
    public static void main1(String[] args) {
        char a = 'A';

        boolean b = true;
        boolean c = 10>20;//10>20计算机转换成 flase

    }
}
